package com.xqboss.apps.constant;

import com.xqboss.apps.service.user.YeepayWalletService;
import com.yeepay.yop.sdk.auth.credentials.provider.YopCredentialsProvider;
import com.yeepay.yop.sdk.auth.credentials.provider.YopCredentialsProviderRegistry;
import com.yeepay.yop.sdk.base.auth.credentials.provider.YopFixedCredentialsProvider;
import com.yeepay.yop.sdk.base.config.YopAppConfig;
import com.yeepay.yop.sdk.config.enums.CertStoreType;
import com.yeepay.yop.sdk.config.provider.file.YopCertConfig;
import com.yeepay.yop.sdk.security.CertTypeEnum;
import com.yeepay.yop.sdk.service.common.YopClient;
import com.yeepay.yop.sdk.service.common.YopClientBuilder;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

@Data
@Configuration
@ConfigurationProperties(prefix = "pay.yeepay", ignoreInvalidFields = true)
public class YeepayConfig {
    /**
     * 用户ID前缀
     */
    private String userPrefix;
    /**
     * 商户号
     */
    private String merchantNo;

    /**
     * 支付回调地址
     */
    private String payNotifyUrl;
    /**
     * 创建钱包回调地址
     */
    private String createWalletNotifyUrl;

    /**
     * 支付跳转地址
     */
    private String payReturnUrl;
    /**
     * 创建钱包跳转地址
     */
    private String createWalletReturnUrl;
    /**
     * 支付宝支付跳转链接
     */
    private String aliPayJumpUrl;


    @Setter(value = AccessLevel.NONE)
    @Getter(value = AccessLevel.NONE)
    private YopClient _yopClient;


    public YopClient getClient(){
        if(_yopClient == null){
            synchronized (YeepayConfig.this){
                if(_yopClient == null){
                    _yopClient = YopClientBuilder.builder().build();
                }
            }
        }
        return _yopClient;
    }


}
